Extension package used with
ggplot2Used to make animations using
ggplots- Can also save rendered plots as gifs
2022-05-16
gganimate? xExtension package used with ggplot2
Used to make animations using ggplots
gganimate?gganimate Basics & Examplesgganimate is primarily applied to ggplot objects by specifying transitions to usetransition_time()transition_reveal()transition_filter()transition_states()Getting started with gganimate could not be easier!
To start, create a regular ggplot. Then, add a transition layer based on what you want to change
transition_time()transition_time() is useful for showing differences in variables over timeLet’s look at the example from the last slide
transition_time() ExampleThis is not very clear, since the trends are very hard to see
Let’s fix that!
shadow_trail()shadow_trail and will keep points behind the moving value, called a shadowshadow_trail() Exampletransition_time() vs transition_reveal()transition_time()transition_time() vs transition_reveal()shadow_trails, we can see what the whole plot looks like using transition_reveal()transition_time() and the animation on the right uses transition_reveal() -
transition_reveal() does a much better job of communicating the data than transition_time() on its own
shadow_wake()shadow_wake() function of gganimate, we can add a wake to these players to show their scoring over their careershadow_wake() is similar to shadow_trail(), but the points eventually fadewake_lengthshadow_wake() -
Shadow_wake() communicates who the most productive players were over the course of their career instead of just a single season
transition_filter()transition_filter()transition_filter() creates an animation that cycles through different filters of the datatransition_states()transition_states() is useful for non-time related transitions between dataSo, let’s look at an example
transition_states() Example(1)transition_states() Example(2)ggplottransition_states() Example(3)transition_states() Example(4)shadow_mark(), we can then add onto the existing plot
shadow_mark() is similar to shadow_trail(), however it leaves a mark at the data state CustomizationLet’s look at an example!
Cars Data SetWith Animate and Labs